<!DOCTYPE html>
<html>
<head>
<title>供电所信息</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport"
			content="width=device-width,initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta content="black" name="apple-mobile-web-app-status-bar-style">
		<meta name="format-detection" content="telephone=no" />
		<meta name="format-detection" content="email=no" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<!--删除默认的苹果工具栏和菜单栏。-->
		<link rel="stylesheet" href="plug-in/ydui/css/ydui.css?rev=@@hash"/>
		<link rel="stylesheet" href="plug-in/ydui/css/demo.css"/>
		<link rel="stylesheet" href="plug-in/Validform/css/style.css"/>
		<script src="plug-in/ydui/js/ydui.flexible.js"></script>
		<style type="text/css">
			.demo-pagetitle{
				position:relative;
				top:10%;
			}
	    	.m-grids-4{
	    		top:20%;
	    		background:transparent;
	    	}
	    	
			.m-grids-4 .grids-item {
				width: 50%;
			}
			.demo-icons [class^="icon-"]:before, .demo-icons [class*=" icon-"]:before { font-size: 0.6rem; color: #FF685D; }
    	</style>
		<link rel="stylesheet" href="webpage/css/login-main.css" />
		<link rel="stylesheet" href="webpage/css/faultfeedback.min.css" />
		<script type="text/javascript">
		</script>
</head>
<body>
	<!-- <div class="div"></div> -->
	<section class="g-flexview">
		<form id="form" name="form" class="registerform" method="post">
		<header class="m-navbar">
        	<a class="navbar-item" onclick="window.history.go(-1)"><i class="back-ico"></i></a>
        	<div class="navbar-center"><span class="navbar-title">修改供电所信息</span></div>
        	<input id="js_submit" class="navbar-right" type="submit" value="提交" />
    	</header>
	    <section class="g-scrollview">
	        <div class="m-cell demo-small-pitch">
	        	<div class="cell-item" style="display:none">
	                <div class="cell-left">id:</div>
	                <div class="cell-right"><input id="id" name="id" type="text" class="cell-input" placeholder="请输入单位编码" autocomplete="off" /></div>
	            </div>
	            <div class="cell-item">
	                <div class="cell-left">单位编码：</div>
	                <div class="cell-right"><input id="comCode" name="comCode" type="text" class="cell-input" placeholder="请输入单位编码" autocomplete="off" /></div>
	            </div>
	            <div class="cell-item">
	                <div class="cell-left">单位名称：</div>
	                <div class="cell-right"><input id="comName" name="comName" type="text" class="cell-input" placeholder="请输入单位名称" autocomplete="off" /></div>
	            </div>
	            <div class="m-cell">
					<label class="cell-item">
						<span class="cell-left">是否激活：</span>
						<label class="cell-right">
							<input id="comStatus" name="comStatus" type="checkbox" class="m-switch"/>
						</label>
					</label>
				</div>
				<button type="button" class="btn-block btn-primary" onclick="js_delete()">删除</button>
			</div>
			
		</section>
		</form>
	</section>
</body>
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="plug-in/ydui/js/ydui.js"></script>
<script src="http://malsup.github.io/jquery.form.js"></script>
<script type="text/javascript" src="plug-in/Validform/js/Validform_v5.3.1_min_zh-cn.js"></script>
<script type="text/javascript" src="plug-in/Validform/js/initValidform.js"></script>
<script type="text/javascript">
	$(function(){
		var name , value;
		var str=location.href; //取得整个地址栏
		var num=str.indexOf("?")
		str=str.substr(num+1); //取得所有参数   stringvar.substr(start [, length ]
		var arr=str.split("&"); //各个参数放到数组里
		for(var i=0;i < arr.length;i++){
			num=arr[i].indexOf("=");
		    if(num>0){
				name=arr[i].substring(0,num);
		        value=arr[i].substr(num+1);
		        this[name]=value;
		    }
		}
		$.ajax({
			type: 'post', // 提交方式 get/post
			async:false,
	   		url: "systemController.do?updateCompaniseDatagrid", // 需要提交的 url
	  		data:{'id':value},
	   		dataType:"json",
	       	success: function(json){
	       		var entity = json.obj;
	       		$("#id").attr('value',json.obj.id);
	       		$("#comCode").attr('value',json.obj.comCode);
	       		$("#comName").attr("value",json.obj.comName);
				if(json.obj.dicStatus==1){
					$("#comStatus").attr("checked","checked");
					$("#comStatus").attr("value",1);
				}else{
					$("#comStatus").attr("value",0);
				}
				return false;
	       	},
	       	error : function(){}
		})
	})
	$('#js_submit').on('click', function(){
		if(!StopSubmit()){
			return false;
		}
		var check=confirm("您确定要提交表单吗？");
		if(!check){
			return false;
		}
		var id = $("#id").val();
		var comCode = $("#comCode").val();
		var comName = $("#comName").val();
		if($("#comStatus").is(':checked')){
			$("#comStatus").attr("value",1);
		}else{
			$("#comStatus").attr("value",0);
		}
		var comStatus = $("#comStatus").val();
		$('#form').on('submit', function(){
			$.ajax({
				type: 'post', // 提交方式 get/post
				async:false,
		   		url: "systemController.do?doUpdateCompanise", // 需要提交的 url
		  		data:$('form').serialize(),
		   		dataType:"json",
		       	success: function(json){ // data 保存提交后返回的数据，一般为 json 数据
		       		alert("更新成功成功");
	        		window.location.href="systemController.do?toCompanise";
	        		return false;
		       	},
		       	error:function(){
		       		alert("您的网络可能出现问题，请重试！");
		       	}
			})
			return false;
		});
	})
	function js_delete(){
		var abc = $("#id").val();
		var r=confirm("确定要删除此信息吗？")
		  if (r==true)
		    {
			  window.location.href = "sysdeleteController.do?departDelete&id="+abc;
		    }
		  else
		    {
		    return false;
		    }
	}
</script>
</html>